package com.sihan.swvp.service.sjfx;


import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sihan.swvp.common.CommonUtil;
import com.sihan.swvp.dao.sjfx.LeadDrivingDao;


@Service
public class LeadDrivingService{

	@Autowired
	private LeadDrivingDao drivingDao;
	
	public Map<String, Object> getTaskWorkByCount(Map<String, Object> param) {
		return drivingDao.getTaskWorkByCount(param);
	}
	public List<Map<String, Object>> getTaskWorkByEachMonthCount(Map<String, Object> params) {
		return drivingDao.getTaskWorkByEachMonthCount(params);
	}
	
	
	//<!-- 根据年份查询-同步视频-每月的条数 -->
	public List<Map<String, Object>> getM_video_count(String parm){
		return drivingDao.getM_video_count(parm);
	}
	
	//<!-- 根据年份查询 违规视频每月数量和违规率 -->
	public List<Map<String, Object>> getwdCount(String year){
		return drivingDao.getwdCount(year);
	}
	
	//<!-- 根据年份查询每月视频关联数量 -->
	public List<Map<String, Object>> getVideoMacth(String year){
		
		return drivingDao.getVideoMacth(year);
	}
	
	//<!-- 巡视任务 -->
	public List<Map<String, Object>> getXschart(){
		return drivingDao.getXschart();
	}
	
	//<!-- 工作任务任务 -->
	public List<Map<String, Object>> getWorkchart(){
		return drivingDao.getWorkchart();
	}
	//今日任务总数（巡视任务、工作任务）
	public List<Map<String, Object>> taskSum_today(){
		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("counts", drivingDao.xsTask_today());
		map.put("name", "巡视任务");
		list.add(map);
		map = new HashMap<String, Object>();
		map.put("counts", drivingDao.workTask_today());
		map.put("name", "工作任务");
		list.add(map);
		return list;
	}
	
	public List<Map<String, Object>> videoSum_today(){
		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("counts", drivingDao.video_manage_today());
		map.put("name", "关联视频");
		list.add(map);
		map = new HashMap<String, Object>();
		map.put("counts", drivingDao.video_syn_today());
		map.put("name", "同步视频");
		list.add(map);
		return list;
	}
	
	public List<Map<String, Object>> taskLv_today(){
		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
		Map<String, Object> map = new HashMap<String, Object>();
		String xslv_today = drivingDao.xslv_today();
		map.put("lv",  xslv_today == null?0:xslv_today);
		map.put("name", "巡视任务");
		list.add(map);
		map = new HashMap<String, Object>();
		String worklv_today = drivingDao.worklv_today();
		map.put("lv", worklv_today == null?0:worklv_today);
		map.put("name", "工作任务");
		list.add(map);
		return list;
	}
	
	public List<Map<String, Object>> videoSyn_week(){
		return drivingDao.videoSyn_week();
	}
	
	public List<Map<String, Object>> videoWd_week(){
		return drivingDao.videoWd_week();
	}
	
	public List<Map<String, Object>> videoManager_week(){
		return drivingDao.videoManager_week();
	}
	
	public List<Map<String, Object>> videoSyn_month(){
		GregorianCalendar c=new GregorianCalendar();
	    c.add(Calendar.DAY_OF_MONTH, -30);
		return drivingDao.videoSyn_month(c.getTime(),new Date());
	}
	
	public List<Map<String, Object>> videoWd_month(){
		GregorianCalendar c=new GregorianCalendar();
	    c.add(Calendar.DAY_OF_MONTH, -30);
		return drivingDao.videoWd_month(c.getTime(),new Date());
	}
	
	public List<Map<String, Object>> videoManager_month(){
		GregorianCalendar c=new GregorianCalendar();
	    c.add(Calendar.DAY_OF_MONTH, -30);
		return drivingDao.videoManager_month(c.getTime(),new Date());
	}
}